//包：为了更好的组织和管理类
//package 定义包，用来表示类所属的包
//import static 静态引入

public class Class {
    //2.静地初始化
    public String name = "李四";
    public int age = 12;

    //Alt + insert 快速生成
    //3.构造函数

    public Class() {
    }

    //使用this()调用其他构造函数
    public Class(String name) {
        this(name, 18);
    }

    public Class(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void print()
    {
        System.out.println(this.name + " " + this.age);
    }
    public static void test1()
    {
        //1.类外初始化
        Class c = new Class();
        c.name = "张三";
        c.age = 12;

        c.print();
    }

    public static void test2 ()
    {
        Class c = new Class();
        c.print();
    }
    public static void test3()
    {
        Class c = new Class("胜胜", 22);
        c.print();
    }

    public static void test4()
    {
        Class c = new Class("赵六");
        c.print();
    }

    //静态代码块
    static {
        System.out.println("静态代码块！");
    }

    {
        System.out.println("初始代码块！");
    }

    //封装：将数据和方法有机结合起来，隐藏对象的属性和实现细节，仅对外公开接口和对象进行交互
    public static void main(String[] args) {
        test1();
        test2();
        test3();
        test4();
    }
}
